package com.ruoyi.project.system.video.controller;

import com.masiyi.ffmpeg.template.FFmpegTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/ff")
public class
FFController {

    @Value("${ffmpeg.path:/default/path/to/ffmpeg}")
    private String ffmpegPath;




    @RequestMapping("/trans")
    public String show(){
        FFmpegTemplate ffmpegTemplate = new FFmpegTemplate(ffmpegPath);
        System.out.println(ffmpegTemplate.extractAudio("D:\\temp\\mvc.mp4"));
        try {
            ffmpegTemplate.execute("ffmpeg -re -i /usr/local/video/mvc.mp4 -vcodec libx264 -acodec aac -c copy -flvflags no_duration_filesize -f flv  -safe 0 rtmp://192.168.198.128:1935/mylive/77");
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        // 视频格式转换
        //ffmpegTemplate.convert("D:\\temp\\mvc.mp4","D:\\temp\\mvc.avi");
        return "success";
    }
}
